package com.hw.frame.utils;
import java.io.IOException;
import java.io.InputStream;

import com.longevitysoft.android.xml.plist.PListXMLHandler;
import com.longevitysoft.android.xml.plist.PListXMLParser;
import com.longevitysoft.android.xml.plist.domain.Array;
import com.longevitysoft.android.xml.plist.domain.Dict;
import com.longevitysoft.android.xml.plist.domain.PList;


public class PListXMLParserUtil {

	protected  PListXMLParser parser;


	public static void testParseValidXMLWorkflow(InputStream xml,String cityName) {
		PListXMLHandler handler = new PListXMLHandler();
		PListXMLParser parser=new PListXMLParser();
		parser.setHandler(handler);
		try {
			parser.parse(xml);
		} catch (IllegalStateException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		PList actualPList = ((PListXMLHandler) parser.getHandler()).getPlist();
		
		System.out.println("=========================>"+ ((Dict) actualPList.getRootElement())
				.getConfigurationArray("city").size());
	
		
		Array citArray=((Dict) actualPList.getRootElement())
				.getConfigurationArray("city");
		
		for (int i = 0; i < citArray.size(); i++) {
			  Dict dict=(Dict) citArray.get(i);
			  String city_name=dict.getConfiguration("CityName").getValue();
			  if (cityName.contains(city_name)) {
                	//  PreferenceTool.put(SP.CITYID, dict.getConfiguration("CityId").getValue());
                	  System.out.println("当前城市id==============="+dict.getConfiguration("CityId").getValue());
      				  PreferenceTool.commit();
                	  
		   }
		}
	    

	}

	

	}